package control
{
	
	
	import flash.events.*;
	import flash.utils.Timer;
	
	import flashx.textLayout.formats.Float;
	
	import mx.controls.Alert;
	
	public class ControlMove
	{
		private var timer:Timer = new Timer(10,54);
		private var _xMove:int;
		private var _yMove:int;
		private var _direction:String;
		public var startposition:Array = new Array();//起点数组
		public var currentposition:Array = new Array();//当前位置数组
		private var _isTimerrun:Boolean;
		
		public function ControlMove()
		{
			isTimerrun = false;
			timer.addEventListener(TimerEvent.TIMER,Move);
		}
		public function get isTimerrun():Boolean
		{
			return _isTimerrun;
		}
		
		public function set isTimerrun(value:Boolean):void
		{
			_isTimerrun = value;
		}
		public function get xMove():int
		{
			return _xMove;
		}
		
		public function set xMove(value:int):void
		{
			_xMove = value;
		}
		
		public function get yMove():int
		{
			return _yMove;
		}
		
		public function set yMove(value:int):void
		{
			_yMove = value;
		}
		public function get direction():String
		{
			return _direction;
		}
		
		public function set direction(value:String):void
		{
			_direction = value;
		}
		
		public function StartTimer():void
		{
			timer.start();
		}
		public function Move(event:TimerEvent):void
		{
			if(direction == "Right")
				xMove = xMove + 1;
			else if(direction == "Left")
				xMove = xMove - 1;
			else if(direction == "Up")
				yMove = yMove - 1;
			else if(direction == "Down")
				yMove = yMove + 1;
		}
		public function StopTimer():void
		{
			timer.stop();
		}
		public function ResetTimer():void
		{
			timer.reset();
			timer.addEventListener(TimerEvent.TIMER,Move);
		}
	}
}